package com.gzucm.Scholarship.controller;

import com.gzucm.Scholarship.dto.ResultDTO;
import com.gzucm.Scholarship.entity.BonusItem;
import com.gzucm.Scholarship.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

@Slf4j
@RestController
@Api(tags = "学生接口")
@RequestMapping("/api/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @PostMapping("/addBonusItem")
    @ApiOperation(value = "添加加分项目", notes = "添加加分项目接口")
    public ResultDTO addBonusItem(@RequestBody @Valid BonusItem item) {
        return studentService.addBonusItem(item);
    }

    @DeleteMapping("/deleteBonusItem/{id}")
    @ApiOperation(value = "删除加分项目", notes = "删除加分项目接口")
    public ResultDTO deleteBonusItemById(@PathVariable("id") String id) {
        return studentService.deleteBonusItemById(id);
    }

    @PostMapping("/addFileById/{id}")
    @ApiOperation(value = "加分项目上传附件材料", notes = "上传附件材料接口")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "加分项id", required = true, dataTypeClass = String.class)
    })
    public ResultDTO addFileById(@PathVariable("id") String id, MultipartFile file) {
        return studentService.addFileById(id, file);
    }

}
